package com.lagou.edu.service.impl;

import com.dubbo.demo.service.SleepService;
import org.apache.dubbo.config.annotation.DubboService;

import java.util.Random;
import java.util.concurrent.TimeUnit;

/**
 * @author liangzj
 * @date 2021/5/22 9:47
 */
@DubboService
public class SleepServiceImpl implements SleepService {

    @Override
    public void methodA() {
        randomSleep();
    }

    @Override
    public void methodB() {
        randomSleep();
    }

    @Override
    public void methodC() {
        randomSleep();
    }

    private void randomSleep() {
        System.out.println("sleep..................");
        Random random = new Random();
        int randomSleepTime = random.nextInt(100);

        try {
            TimeUnit.MILLISECONDS.sleep(randomSleepTime);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
